Define halt() and safe_halt() properly for Linux-on-Xen. Remove duplicated
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Tue, 30 May 2006 12:29:29 +0000 (13:29 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Tue, 30 May 2006 12:29:29 +0000 (13:29 +0100)
code for initial bringup of secondary VCPUs.
Signed-off-by: Keir Fraser <keir@xensource.com>
linux-2.6-xen-sparse/arch/i386/kernel/process-xen.c
linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c
linux-2.6-xen-sparse/arch/x86_64/kernel/process-xen.c
linux-2.6-xen-sparse/drivers/xen/core/smpboot.c
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/system.h
linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/system.h
linux-2.6-xen-sparse/include/xen/cpu_hotplug.h

index 162ea42dd91d2e18da2ac5994a08efd90ac1a377..e6724a00b1fdf0a805d9b30870e1aaf08cc0b73b 100644 (file)
@@ -55,6 +55,7 @@
 
 #include <xen/interface/physdev.h>
 #include <xen/interface/vcpu.h>
+#include <xen/cpu_hotplug.h>
 
 #include <linux/err.h>
 
@@ -101,8 +102,6 @@ void enable_hlt(void)
 EXPORT_SYMBOL(enable_hlt);
 
 /* XXX XEN doesn't use default_idle(), poll_idle(). Use xen_idle() instead. */
-extern void stop_hz_timer(void);
-extern void start_hz_timer(void);
 void xen_idle(void)
 {
        local_irq_disable();
@@ -112,10 +111,7 @@ void xen_idle(void)
        else {
                clear_thread_flag(TIF_POLLING_NRFLAG);
                smp_mb__after_clear_bit();
-               stop_hz_timer();
-               /* Blocking includes an implicit local_irq_enable(). */
-               HYPERVISOR_block();
-               start_hz_timer();
+               safe_halt();
                set_thread_flag(TIF_POLLING_NRFLAG);
        }
 }
@@ -132,11 +128,7 @@ static inline void play_dead(void)
        cpu_clear(smp_processor_id(), cpu_initialized);
        preempt_enable_no_resched();
        HYPERVISOR_vcpu_op(VCPUOP_down, smp_processor_id(), NULL);
-       /* Same as drivers/xen/core/smpboot.c:cpu_bringup(). */
-       cpu_init();
-       touch_softlockup_watchdog();
-       preempt_disable();
-       local_irq_enable();
+       cpu_bringup();
 }
 #else
 static inline void play_dead(void)
index 7c12f7b9fbf9fd5acb7a6617bfafa1076f6f69d7..575596e3ee3dce27959625c9382ed6e7f7650859 100644 (file)
@@ -973,7 +973,7 @@ EXPORT_SYMBOL(jiffies_to_st);
  * stop_hz_timer / start_hz_timer - enter/exit 'tickless mode' on an idle cpu
  * These functions are based on implementations from arch/s390/kernel/time.c
  */
-void stop_hz_timer(void)
+static void stop_hz_timer(void)
 {
        unsigned int cpu = smp_processor_id();
        unsigned long j;
@@ -993,11 +993,27 @@ void stop_hz_timer(void)
        BUG_ON(HYPERVISOR_set_timer_op(jiffies_to_st(j)) != 0);
 }
 
-void start_hz_timer(void)
+static void start_hz_timer(void)
 {
        cpu_clear(smp_processor_id(), nohz_cpu_mask);
 }
 
+void safe_halt(void)
+{
+       stop_hz_timer();
+       /* Blocking includes an implicit local_irq_enable(). */
+       HYPERVISOR_block();
+       start_hz_timer();
+}
+EXPORT_SYMBOL(safe_halt);
+
+void halt(void)
+{
+       if (irqs_disabled())
+               HYPERVISOR_vcpu_op(VCPUOP_down, smp_processor_id(), NULL);
+}
+EXPORT_SYMBOL(halt);
+
 /* No locking required. We are only CPU running, and interrupts are off. */
 void time_resume(void)
 {
index 6e4e62e86c30f6df152fcca72132bafba0b9a5d3..ca96708d1cf9d5575731983450175b3b5a267203 100644 (file)
@@ -60,6 +60,8 @@
 #include <asm/ia32.h>
 #include <asm/idle.h>
 
+#include <xen/cpu_hotplug.h>
+
 asmlinkage extern void ret_from_fork(void);
 
 unsigned long kernel_thread_flags = CLONE_VM | CLONE_UNTRACED;
@@ -118,8 +120,6 @@ void exit_idle(void)
 }
 
 /* XXX XEN doesn't use default_idle(), poll_idle(). Use xen_idle() instead. */
-extern void stop_hz_timer(void);
-extern void start_hz_timer(void);
 void xen_idle(void)
 {
        local_irq_disable();
@@ -129,10 +129,7 @@ void xen_idle(void)
        else {
                clear_thread_flag(TIF_POLLING_NRFLAG);
                smp_mb__after_clear_bit();
-               stop_hz_timer();
-               /* Blocking includes an implicit local_irq_enable(). */
-               HYPERVISOR_block();
-               start_hz_timer();
+               safe_halt();
                set_thread_flag(TIF_POLLING_NRFLAG);
        }
 }
@@ -145,11 +142,7 @@ static inline void play_dead(void)
        cpu_clear(smp_processor_id(), cpu_initialized);
        preempt_enable_no_resched();
        HYPERVISOR_vcpu_op(VCPUOP_down, smp_processor_id(), NULL);
-       /* Same as drivers/xen/core/smpboot.c:cpu_bringup(). */
-       cpu_init();
-       touch_softlockup_watchdog();
-       preempt_disable();
-       local_irq_enable();
+       cpu_bringup();
 }
 #else
 static inline void play_dead(void)
index c4995d838c24c6a828417e4d70ea441c1ef1e749..5c6a16579b8fb66d4d08defc231629cf235000d5 100644 (file)
@@ -150,12 +150,17 @@ static void xen_smp_intr_exit(unsigned int cpu)
 }
 #endif
 
-static void cpu_bringup(void)
+void cpu_bringup(void)
 {
        cpu_init();
        touch_softlockup_watchdog();
        preempt_disable();
        local_irq_enable();
+}
+
+static void cpu_bringup_and_idle(void)
+{
+       cpu_bringup();
        cpu_idle();
 }
 
@@ -180,7 +185,7 @@ void cpu_initialize_context(unsigned int cpu)
        ctxt.user_regs.fs = 0;
        ctxt.user_regs.gs = 0;
        ctxt.user_regs.ss = __KERNEL_DS;
-       ctxt.user_regs.eip = (unsigned long)cpu_bringup;
+       ctxt.user_regs.eip = (unsigned long)cpu_bringup_and_idle;
        ctxt.user_regs.eflags = X86_EFLAGS_IF | 0x1000; /* IOPL_RING1 */
 
        memset(&ctxt.fpu_ctxt, 0, sizeof(ctxt.fpu_ctxt));
index 6c9db21d05b56f819b3aea163b95a3f72e6d1fe5..2626b98908d451f7ab34430a67bf4ab53aa6ff37 100644 (file)
@@ -625,8 +625,8 @@ do {                                                                        \
                preempt_enable_no_resched();                            \
 } while (0)
 
-#define safe_halt()            ((void)0)
-#define halt()                 ((void)0)
+void safe_halt(void);
+void halt(void);
 
 #define __save_and_cli(x)                                              \
 do {                                                                   \
index bde56ce43c13f3a82851d9d161b89d328995f552..9826fa7269f4d719f6a0d635128a5740d4e2386f 100644 (file)
@@ -424,8 +424,8 @@ do {                                                                        \
        preempt_enable_no_resched();                                    \
        ___x; })
 
-#define safe_halt()            ((void)0)
-#define halt()                 ((void)0)
+void safe_halt(void);
+void halt(void);
 
 void cpu_idle_wait(void);
 
index 6df85f949f5c28492b3d4499c6961135db866431..fad14d8393ee9cfabc3eefb49d85d930c08efccc 100644 (file)
@@ -18,6 +18,8 @@ void init_xenbus_allowed_cpumask(void);
 int smp_suspend(void);
 void smp_resume(void);
 
+void cpu_bringup(void);
+
 #else /* !defined(CONFIG_HOTPLUG_CPU) */
 
 #define cpu_up_check(cpu)              (0)